package 构建模式;

import testJ.test1;

public class 构建者模式 {
    public static void main(test1[] args) {
        Request1 request = Request1.RequestBuilder.build().frequentOk(true).loggedOn(true).builderRequest();

    }
}
//模拟请求
class Request1{
    private boolean loggedOn;
    private boolean frequentOk;

    public Request1(boolean loggedOn, boolean frequentOk) {
        this.loggedOn = loggedOn;
        this.frequentOk = frequentOk;
    }
    //建造者模式
    public static class RequestBuilder{
        private boolean loggedOn;
        private boolean frequentOk;
        public static RequestBuilder build(){
            return new RequestBuilder();
        }
        public  RequestBuilder loggedOn(boolean loggedOn){
            this.loggedOn = loggedOn;
            return this;
        }
        public RequestBuilder frequentOk(boolean frequentOk){
            this.frequentOk = frequentOk;
            return this;
        }
        public Request1 builderRequest(){
            return new Request1(this.loggedOn,this.frequentOk);
        }
    }
}